# -*- coding: utf-8 -*- 
from django.db import models


class User(models.Model):
    mail = models.EmailField(unique=True)
    passwd = models.CharField(max_length=32, verbose_name='密码')
    block =  models.BooleanField(default=False)
    record_time = models.DateTimeField(auto_now_add=True)
    last_time = models.DateTimeField(auto_now=True)

    class Meta:
        verbose_name = '用户'
        verbose_name_plural = '用户'

    def __unicode__(self):
        return self.mail

class Innerword(models.Model):
    num = models.CharField(max_length=8, primary_key=True, verbose_name='编号')
    writer = models.ForeignKey(User, verbose_name='作者')
    type = models.CharField(max_length=6, verbose_name='类型')
    content = models.CharField(max_length=140, verbose_name='心语')
    flowers = models.IntegerField(default=0, verbose_name='鲜花')
    eggs = models.IntegerField(default=0, verbose_name='鸡蛋')
    block = models.BooleanField(default=False)
    spam = models.IntegerField(default=0)
    city = models.CharField(max_length=20, verbose_name='市')
    create_time = models.DateTimeField(auto_now_add=True)
    last_mod = models.DateTimeField(auto_now=True)

    class Meta:
        verbose_name = '心语'
        verbose_name_plural = '心语'

    def __unicode__(self):
        return self.num
